package com.jinmdz.app.dao.dao;

import com.jinmdz.app.dao.dao.provider.FuneralBusinessProvider;
import com.jinmdz.app.dao.model.funeral.FuneralBusinessItem;
import com.jinmdz.app.dao.model.funeral.FuneralBusinessViewItem;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultType;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;

/**
 * 殡葬业务Dao
 *
 * @author LiCongLu
 * @date 2020-02-06 9:02
 */
public interface FuneralBusinessDao {

    /**
     * 获取最后一个业务编码
     *
     * @param
     * @return
     * @author LiCongLu
     * @date 2020-02-06 9:42
     */
    @Select(" select business_code from funeral_business order by id desc limit 1 ")
    @ResultType(String.class)
    String getBusinessCodeAsLast();

    /**
     * 按照业务编码获取未删除的殡葬信息
     *
     * @param businessCode 殡葬业务编码
     * @return
     * @author LiCongLu
     * @date 2020-02-07 8:58
     */
    @Select(" select id,business_code,dead_name,member_name,remark,version " +
            " from funeral_business where business_code = #{businessCode} and deleted=0 limit 1 ")
    FuneralBusinessItem getFuneralBusinessByBusinessCode(@Param("businessCode") String businessCode);

    /**
     * 按照业务编码获取未删除的殡葬信息主键
     *
     * @param businessCode 殡葬业务编码
     * @return
     * @author LiCongLu
     * @date 2020-02-07 8:53
     */
    @SelectProvider(type = FuneralBusinessProvider.class, method = "getFuneralBusinessViewByBusinessCode")
    FuneralBusinessViewItem getFuneralBusinessViewByBusinessCode(@Param("businessCode") String businessCode);
}
